home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Text Editor / Source / TextEditor.r < prev    next >
Encoding:
Text File  |  1995-12-13  |  14.7 KB  |  719 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TextEditor.r
  3.  
  4.     Contains:    TextEditor Resources
  5.  
  6.     Written by:    Steve Smith
  7.  
  8.     Copyright:    © 1994-95 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #define SystemSevenOrBetter 1            // we want the extended types
  12. #define    SystemSevenOrLater    1            // Types.r uses this variable
  13.  
  14. #define qRezzing 1                        // Flag for our Def file.
  15.  
  16. // -- Macintosh Includes --
  17.  
  18. #include "Types.r"
  19. #include "SysTypes.r"
  20. #include "CodeFragmentTypes.r"
  21.  
  22. // -- OpenDoc Includes --
  23.  
  24. #ifndef __ODTYPES_R__
  25. #include "ODTypes.r"
  26. #endif
  27.  
  28. #ifndef SOM_Module_OpenDoc_StdDefs_defined
  29. #include "StdDefs.r"
  30. #endif
  31.  
  32. // -- Text Editor Includes --
  33.  
  34. #ifndef _TEXTEDITORDEF_
  35. #include "TextEditorDef.h"
  36. #endif
  37.  
  38. #ifndef _TEXTEDITORVERS_
  39. #include "TextEditorVers.h"
  40. #endif
  41.  
  42. //-------------------------------------------------------------------------------------
  43. // .rsrc resources
  44. //-------------------------------------------------------------------------------------
  45.  
  46. // TextEditor - This gets the resources from my .rsrc file (PICTs etc.)
  47. include "TextEditorOther.rsrc";
  48.  
  49. //-------------------------------------------------------------------------------------
  50. // Version Resources
  51. //-------------------------------------------------------------------------------------
  52.  
  53. resource 'vers' (1) 
  54. {
  55.     currentMajorVersion,
  56.     finderMinorVersion,
  57.     developmentStage,
  58.     preReleaseNumber,
  59.     verUS,
  60.     shortVersionStr,
  61.     shortVersionStr", © Apple Computer, Inc. 1994-1995"
  62. };
  63.  
  64. resource 'vers' (2) 
  65. {
  66.     currentMajorVersion,
  67.     finderMinorVersion,
  68.     developmentStage,
  69.     preReleaseNumber,
  70.     verUS,
  71.     "",
  72.     "OpenDoc™ Sample Code"
  73. };
  74.  
  75. //-------------------------------------------------------------------------------------
  76. // Code Fragment Resource
  77. //-------------------------------------------------------------------------------------
  78.  
  79. resource 'cfrg' (0) 
  80. {
  81.     {    /* [1] */
  82. #ifdef _68KBUILD_
  83.         kMotorola,
  84. #else
  85.         kPowerPC,
  86. #endif
  87.         kFullLib,
  88.         currentVersion,
  89.         compatibleVersion,
  90.         kDefaultStackSize,
  91.         kNoAppSubFolder,
  92.         kIsLib,
  93.         kOnDiskFlat,
  94.         kZeroOffset,
  95.         kWholeFork,
  96.         kTextEditorID,        /* this must be the class ID */
  97.  
  98.         /* [2] */
  99. #ifdef _68KBUILD_
  100.         kMotorola,
  101. #else
  102.         kPowerPC,
  103. #endif
  104.         kFullLib,
  105.         currentVersion,
  106.         compatibleVersion,
  107.         kDefaultStackSize,
  108.         kNoAppSubFolder,
  109.         kIsLib,
  110.         kOnDiskFlat,
  111.         kZeroOffset,
  112.         kWholeFork,
  113.         kPartClassName        /* this must be the part class name */
  114.     }
  115. };
  116.  
  117. //-------------------------------------------------------------------------------------
  118. // NMAP Resources
  119. //-------------------------------------------------------------------------------------
  120.  
  121. // Map a part's kind (unique content identifier)
  122. // to a generic content category identifier
  123. resource kODNameMappings (kKindCategoryMapId) 
  124. {
  125.     kODKind,
  126.     {    /* array Types: 1 element */
  127.         /* [1] */
  128.         kTextEditorKind,
  129.         kODIsAnISOStringList
  130.         {
  131.             {    /* array ClassIDs: 1 element */
  132.                 /* [1] */
  133.                 kODCategoryStyledText
  134.             }
  135.         }
  136.     }
  137. };
  138.  
  139. // Map a part's class id (module::classname)
  140. // to a part's kind (unique content identifier)
  141. resource kODNameMappings (kEditorKindMapId) 
  142. {
  143.     kODEditorKinds,
  144.     {    /* array Types: 1 element */
  145.         /* [1] */
  146.         kTextEditorID,
  147.         kODIsAnISOStringList
  148.         {
  149.             {    /* array ClassIDs: 1 element */
  150.                 /* [1] */
  151.                 kTextEditorKind
  152.             }
  153.         }
  154.     }
  155. };
  156.  
  157. // Map a part's class id (module::classname)
  158. // to the part editor's name
  159. resource kODNameMappings (kEditorUserStringMapId) 
  160. {
  161.     kODEditorUserString,
  162.     {    /* array Types: 1 element */
  163.         /* [1] */
  164.         kTextEditorID,
  165.         kODIsINTLText
  166.         {
  167.             smRoman,
  168.             langEnglish,
  169.             kTextEditorEditorUserString
  170.         }
  171.     }
  172. };
  173.  
  174. // Map a part's kind (unique content identifier)
  175. // to a human readable string.
  176. resource kODNameMappings (kKindUserStringMapId) 
  177. {
  178.     kODKindUserString,
  179.     {    /* array Types: 1 element */
  180.         /* [1] */
  181.         kTextEditorKind,
  182.         kODIsINTLText
  183.         {
  184.             smRoman,
  185.             langEnglish,
  186.             kTextEditorKindUserString
  187.         }
  188.     }
  189. };
  190.  
  191. // Map a part's kind (unique content identifier)
  192. // to an old style MacOS Type (and/or ScrapType)
  193. resource kODNameMappings (kOldMacOSTypeMapId) 
  194. {
  195.     kODKindOldMacOSType,
  196.     {    /* array KeyList: 1 element */
  197.         /* [1] */
  198.         kTextEditorKind,
  199.         kODIsMacOSType {
  200.             kTextEditorDocumentOSType
  201.         }
  202.     }
  203. };
  204.  
  205. // Map a part's class id (module::classname) to
  206. // the data/file OSTypes the part supports.
  207. resource kODNameMappings (kPlatformEditorKindMapId) 
  208. {
  209.     kODEditorPlatformKind,
  210.     {    /* array KeyList: 1 element */
  211.         /* [1] */
  212.         kTextEditorID,
  213.         kODIsPltfmTypeSpac {
  214.             /* array PltfmTypeSpacList: 3 elements */
  215.             {
  216.                 /* [1] */
  217.                 kODPlatformDataType, 
  218.                 kSTXTDataKind,
  219.                 smRoman,
  220.                 langEnglish,
  221.                 kSTXTDataKindUserString,
  222.                 kODCategoryStyledText,
  223.  
  224.                 /* [2] */
  225.                 kODPlatformFileType, 
  226.                 kTextFileKind,
  227.                 smRoman,
  228.                 langEnglish,
  229.                 kTextFileKindUserString,
  230.                 kODCategoryPlainText,
  231.                 
  232.                 /* [3] */
  233.                 kODPlatformDataType, 
  234.                 kTextDataKind,
  235.                 smRoman,
  236.                 langEnglish,
  237.                 kTextDataKindUserString,
  238.                 kODCategoryPlainText,
  239.             }
  240.         }
  241.     }
  242. };
  243.  
  244. //-------------------------------------------------------------------------------------
  245. // User Visible Strings
  246. //-------------------------------------------------------------------------------------
  247.  
  248. resource 'STR#' (kRuntimeStringsID, "Menu Items")
  249. {
  250.     {    
  251.         // File Names
  252.         "Text Editor Preferences",
  253.         
  254.         // Menu Text
  255.         "About Text Editor…",
  256.         "Text Editor Preferences…",
  257.         "Preferences…",
  258.         "Show Ruler",
  259.         "Hide Ruler",
  260.         "Show ScriptRunner",
  261.         "Hide ScriptRunner"
  262.     }
  263. };
  264.  
  265. resource 'STR#' (kErrorStringsID, "Error strings") 
  266. {
  267.     {    
  268.         /* [1] */
  269.         "“TextEditor” was unable completely initi"
  270.         "alize it’s internal structures.",
  271.         
  272.         /* [2] */
  273.         "“TextEditor” was unable to open the docu"
  274.         "ment due to unforseen circumstances.",
  275.         
  276.         /* [3] */
  277.         "“TextEditor” was unable to open a part w"
  278.         "indow due to unforseen circumstances.",
  279.         
  280.         /* [4] */
  281.         "“TextEditor” has been asked to remove a "
  282.         "frame that does not belong to it, or an "
  283.         "error occurred while removing the frame "
  284.         "from internal storage.",
  285.         
  286.         /* [5] */
  287.         "A window that “TextEditor” created has b"
  288.         "een deleted without its knowledge. This "
  289.         "may generate a fatal error in the near f"
  290.         "uture. Please close the document immedia"
  291.         "tely to prevent data loss.",
  292.         
  293.         /* [6] */
  294.         "“TextEditor” was unable to translate the"
  295.         " data on the clipboard due to unforseen "
  296.         "circumstances.",
  297.         
  298.         /* [7] */
  299.         "“TextEditor” was unable to create an obj"
  300.         "ect needed for the basic operation of th"
  301.         "e part. You may be low on memory.",
  302.         
  303.         /* [8] */
  304.         "Display in multiple windows has not been"
  305.         " implemented in this version of the “Tex"
  306.         "tEditor”. A future version may provide t"
  307.         "his feature.",
  308.         
  309.         /* [9] */
  310.         "“TextEditor” encountered a fatal error w"
  311.         "hile trying to save. Try saving again or"
  312.         " closing the document."
  313.     }
  314. };
  315.  
  316. //-------------------------------------------------------------------------------------
  317. // Finder Related Resources
  318. //-------------------------------------------------------------------------------------
  319.  
  320. // Kind resources affect the text Finder displays in the
  321. // "kind" column and file info dialog. This feature was
  322. // introduced as part of Macintosh Easy Open.
  323.  
  324. resource 'kind' (kBaseResourceID) 
  325. {
  326.     kTextEditorEditorOSType,
  327.     0, /* region = USA */
  328.     {
  329.         'shlb', "OpenDoc™ editor"
  330.     }
  331. };
  332.     
  333. resource 'kind' (kBaseResourceID+1) 
  334. {
  335.     kTextEditorViewerOSType,
  336.     0, /* region = USA */
  337.     {
  338.         'shlb', "OpenDoc™ viewer"
  339.     }
  340. };
  341.  
  342. resource 'kind' (kBaseResourceID+2) 
  343. {
  344.     kODShellSignature,
  345.     0, /* region = USA */
  346.     {
  347.         kTextEditorDocumentOSType,   "TextEditor 1.0 document",
  348.         kTextEditorStationeryOSType, "TextEditor 1.0 stationery"
  349.     }
  350. };
  351.  
  352. // The -16397 string will be displayed by Finder when a user
  353. // tries to open the editor shared library. The string should
  354. // give the user a little detail about the part's capabilities
  355. // and enough information to install the part in the correct location.
  356.  
  357. resource 'STR ' (-16397, purgeable) 
  358. {
  359.     "OpenDoc editor\n"
  360.     "\n"
  361.     "“Text Editor” manipulates text data. To work properly, it "
  362.     "should be placed in the Editors folder. To create a new document, open "
  363.     "a stationery pad."
  364. };
  365.  
  366. //-------------------------------------------------------------------------------------
  367. // Menu Resources
  368. //-------------------------------------------------------------------------------------
  369.  
  370. resource 'MENU' (kFontMenuID) 
  371. {
  372.     kFontMenuID,
  373.     textMenuProc,
  374.     allEnabled,
  375.     enabled,
  376.     "Font",
  377.     {
  378.     }
  379. };
  380.  
  381. resource 'MENU' (kSizeMenuID) 
  382. {
  383.     kSizeMenuID,
  384.     textMenuProc,
  385.     0b11111111111111111111110111111111,
  386.     enabled,
  387.     "Size",
  388.     {
  389.         "9 point",    noIcon, noKey, noMark, plain,
  390.         "10",        noIcon, noKey, noMark, plain,
  391.         "12",        noIcon, noKey, noMark, plain,
  392.         "14",        noIcon, noKey, noMark, plain,
  393.         "18",        noIcon, noKey, noMark, plain,
  394.         "24",        noIcon, noKey, noMark, plain,
  395.         "36",        noIcon, noKey, noMark, plain,
  396.         "48",        noIcon, noKey, noMark, plain,
  397.         "72",        noIcon, noKey, noMark, plain,
  398.         "-",        noIcon, noKey, noMark, plain,
  399.         "Other…",    noIcon, noKey, noMark, plain
  400.     }
  401. };
  402.  
  403. resource 'MENU' (kStyleMenuID) 
  404. {
  405.     kStyleMenuID,
  406.     textMenuProc,
  407.     0b11111111111111111111111111111101,
  408.     enabled,
  409.     "Style",
  410.     {
  411.         "Plain Text",    noIcon, "T",   noMark, plain,
  412.         "-",            noIcon, noKey, noMark, plain,
  413.         "Bold",            noIcon, "B",   noMark, bold,
  414.         "Italic",        noIcon, "I",   noMark, italic,
  415.         "Underline",    noIcon, "U",   noMark, underline,
  416.         "Outline",        noIcon, noKey, noMark, outline
  417.     }
  418. };
  419.  
  420. resource 'MENU' (kFormatMenuID) 
  421. {
  422.     kFormatMenuID,
  423.     textMenuProc,
  424.     0b11111111111111111111111111111101,
  425.     enabled,
  426.     "Format",
  427.     {    
  428.         "Hide Ruler", noIcon, "H", noMark, plain,
  429.         "-", noIcon, noKey, noMark, plain,
  430.         "Settings…", noIcon, noKey, noMark, plain
  431.     }
  432. };
  433.  
  434. resource 'MENU' (kToolsMenuID) 
  435. {
  436.     kToolsMenuID,
  437.     textMenuProc,
  438.     allEnabled,
  439.     enabled,
  440.     "Tools",
  441.     {
  442.         "Show ScriptRunner", noIcon, noKey, noMark, plain
  443.     }
  444. };
  445.  
  446. resource 'MENU' (kFontPopupMenuID) 
  447. {
  448.     kFontPopupMenuID,
  449.     3,
  450.     allEnabled,
  451.     enabled,
  452.     "FontPopup",
  453.     {
  454.     }
  455. };
  456.  
  457. //-------------------------------------------------------------------------------------
  458. // Dialog Resources
  459. //-------------------------------------------------------------------------------------
  460.  
  461. // •• About Box Dialog ••
  462.  
  463. resource 'DLOG' (kAboutDialogID, "About Box") 
  464. {
  465.     {0, 0, 250, 350},
  466.     dBoxProc,
  467.     invisible,
  468.     goAway,
  469.     0x0,
  470.     kAboutDialogID,
  471.     "",
  472.     alertPositionMainScreen
  473. };
  474.  
  475. resource 'DITL' (kAboutDialogID) 
  476. {
  477.     {    /* array DITLarray: 8 elements */
  478.         /* [1] */
  479.         {222, 270, 242, 338}, Button { enabled, "OK" },
  480.         /* [2] */
  481.         {24, 25, 56, 57}, Icon { disabled, kEditorIconPicture },
  482.         /* [3] */
  483.         {13, 68, 237, 69}, Button { disabled, "" },
  484.         /* [4] */
  485.         {64, 13, 65, 337}, Button { disabled, "" },
  486.         /* [5] */
  487.         {46, 76, 62, 172}, StaticText { disabled, "Text Editor" },
  488.         /* [6] */
  489.         {76, 76, 116, 304}, StaticText { disabled,
  490.             "Text Editor is a sample part editor which illustrates the functionality "
  491.             "of a non-embedding styled text editor." },
  492.         /* [7] */
  493.         {124, 76, 152, 304}, StaticText { disabled,
  494.             "Written by Steve Smith and Troy Gaul with support from "
  495.             "the OpenDoc™ Engineering team." },
  496.         /* [8] */
  497.         {172, 76, 200, 300}, StaticText { disabled,
  498.             "Copyright © 1994 - 1995 by Apple Computer, Inc. All Rights Reserved." },
  499.         /* [9] */
  500.         {51, 272, 64, 340}, StaticText { disabled,
  501.             "Version "shortVersionStr }
  502.     }
  503. };
  504.  
  505. resource 'dctb' (kAboutDialogID) 
  506. {
  507.     {    /* array ColorSpec: 5 elements */
  508.         /* [1] */
  509.         wContentColor, 59127, 59127, 59127,
  510.         /* [2] */
  511.         wFrameColor, 0, 0, 0,
  512.         /* [3] */
  513.         wTextColor, 0, 0, 0,
  514.         /* [4] */
  515.         wHiliteColor, 0, 0, 0,
  516.         /* [5] */
  517.         wTitleBarColor, 65535, 65535, 65535
  518.     }
  519. };
  520.  
  521. data 'ictb' (kAboutDialogID) 
  522. {
  523.     /* dialog control text styling */
  524.     $"0000000000000000002800240028"
  525.     $"004C80070074800700888007009C"
  526.     $"800700B0800700C4000000000000"
  527.     $"000300007FFF7FFF7FFF0001FFFF"
  528.     $"FFFFFFFF00020000000000000003"
  529.     $"FFFFFFFFFFFF0000000000000003"
  530.     $"00007FFF7FFF7FFF0001FFFFFFFF"
  531.     $"FFFF00020000000000000003FFFF"
  532.     $"FFFFFFFF00D80100000E00000000"
  533.     $"0000FFFFFFFFFFFF000000E10000"
  534.     $"0009000000000000FFFFFFFFFFFF"
  535.     $"000000E800000009000000000000"
  536.     $"FFFFFFFFFFFF000000EF00000009"
  537.     $"000000000000FFFFFFFFFFFF0000"
  538.     $"00F600000009000000000000FFFF"
  539.     $"FFFFFFFF00000850616C6174696E"
  540.     $"6F0647656E6576610647656E6576"
  541.     $"610647656E6576610647656E6576"
  542.     $"61"
  543. };
  544.  
  545. // -- Error Box Dialog --
  546.  
  547. resource 'DLOG' (kErrorBoxID, "Error Box") 
  548. {
  549.     {57, 46, 244, 374},
  550.     dBoxProc,
  551.     invisible,
  552.     goAway,
  553.     0x0,
  554.     kErrorBoxID,
  555.     "",
  556.     alertPositionMainScreen
  557. };
  558.  
  559. resource 'DITL' (kErrorBoxID) 
  560. {
  561.     {    /* array DITLarray: 5 elements */
  562.         /* [1] */
  563.         {153, 256, 173, 314}, Button { enabled, "OK" },
  564.         /* [2] */
  565.         {153, 185, 173, 243}, Button { enabled, "Cancel" },
  566.         /* [3] */
  567.         {11, 70, 124, 317}, StaticText { disabled,
  568.             "<< Use this for errors in the Editor, such as out of memory, "
  569.             "unable to acquire some system resource, etc.>> \nUser errors "
  570.             "use a standard alert appearance. See DITL 129.>>" },
  571.         /* [4] */
  572.         {11, 19, 43, 51}, Icon { disabled, kEditorIconPicture },
  573.         /* [5] */
  574.         {149, 252, 177, 318}, UserItem { disabled }
  575.     }
  576. };
  577.  
  578. /*
  579.  
  580.         •••
  581.         Since these dialogs are graphically-oriented, we will include
  582.         them from the .rsrc file rather than including the Rez version
  583.         here.
  584.         •••
  585.         
  586.         Dialogs that can be found in the .rsrc file are those with the
  587.         following IDs:
  588.             kPreferencesDialogID
  589.             kSettingsDialogID
  590.             kSettingsNoMarginsDialogID
  591.             kOtherSizeDialogID
  592. */
  593.  
  594.  
  595. #define Geneva        3
  596.  
  597. resource 'finf' (kDialogFontInfoID, "Dialog Font Info") 
  598. {
  599.     {    /* array Fonts: 3 elements */
  600.         /* [1] */
  601.         Geneva, plain, 10,
  602.         /* [2] */
  603.         Geneva, plain, 10,
  604.         /* [3] */
  605.         Geneva, plain, 10,
  606.     }
  607. };
  608.  
  609. //-------------------------------------------------------------------------------------
  610. // Finder Bundle Information
  611. //-------------------------------------------------------------------------------------
  612.  
  613. resource 'BNDL' (kDocumentBundle, "Document BNDL") 
  614. {
  615.     kODShellSignature,
  616.     0,
  617.     {    /* array TypeArray: 2 elements */
  618.         /* [1] */
  619.         'FREF',
  620.         {    /* array IDArray: 2 elements */
  621.             /* [1] */
  622.             0, kDocumentFREF,
  623.             /* [2] */
  624.             1, kStationeryFREF
  625.         },
  626.         /* [2] */
  627.         'ICN#',
  628.         {    /* array IDArray: 2 elements */
  629.             /* [1] */
  630.             0, kDocumentIcons,
  631.             /* [2] */
  632.             1, kStationeryIcons
  633.         }
  634.     }
  635. };
  636.  
  637. resource 'BNDL' (kEditorBundle, "Editor BNDL") 
  638. {
  639.     kTextEditorEditorOSType,
  640.     0,
  641.     {    /* array TypeArray: 2 elements */
  642.         /* [1] */
  643.         'FREF',
  644.         {    /* array IDArray: 1 element */
  645.             /* [1] */
  646.             0, kEditorFREF
  647.         },
  648.         /* [2] */
  649.         'ICN#',
  650.         {    /* array IDArray: 1 element */
  651.             /* [1] */
  652.             0, kEditorIcons
  653.         }
  654.     }
  655. };
  656.  
  657. resource 'BNDL' (kViewerBundle, "Viewer BNDL") 
  658. {
  659.     kTextEditorViewerOSType,
  660.     0,
  661.     {    /* array TypeArray: 2 elements */
  662.         /* [1] */
  663.         'FREF',
  664.         {    /* array IDArray: 1 element */
  665.             /* [1] */
  666.             0, kViewerFREF
  667.         },
  668.         /* [2] */
  669.         'ICN#',
  670.         {    /* array IDArray: 1 element */
  671.             /* [1] */
  672.             0, kViewerIcons
  673.         }
  674.     }
  675. };
  676.  
  677. resource 'FREF' (kDocumentFREF) 
  678. {
  679.     kTextEditorDocumentOSType,
  680.     0,
  681.     ""
  682. };
  683.  
  684. resource 'FREF' (kStationeryFREF) 
  685. {
  686.     kTextEditorStationeryOSType,
  687.     1,
  688.     ""
  689. };
  690.  
  691. resource 'FREF' (kEditorFREF) 
  692. {
  693.     'shlb',
  694.     0,
  695.     ""
  696. };
  697.  
  698. resource 'FREF' (kViewerFREF) 
  699. {
  700.     'shlb',
  701.     0,
  702.     ""
  703. };
  704.  
  705. data kODShellSignature (0, "Owner resource") 
  706. {
  707.     $"00"
  708. };
  709.  
  710. data kTextEditorEditorOSType (0, "Owner resource") 
  711. {
  712.     $"00"
  713. };
  714.  
  715. data kTextEditorViewerOSType (0, "Owner resource") 
  716. {
  717.     $"00"
  718. };
  719.